﻿using Microsoft.AspNetCore.Mvc;
using SportsPlatform.Dto.SportBusiness.Category;
using SportsPlatform.SportBusiness.ISportBusiness;
using SportsPlatform.Base;
using SportsPlatform.Query.SportBusiness.Category;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SportsPlatform.Query.SportBusiness.Project;
using SportsPlatform.PermissionManagement.IPermissionManagement;
using SportsPlatform.Dto.SportBusiness.ProjectType;
using SportsPlatform.Filters;

namespace SportsPlatform.Controllers
{
    /// <summary>
    /// 项目管理控制器
    /// </summary>
    [ActionAuthorization]
    [Route("api/[controller]/[action]")]

    public class ProjectController : SportsPlatformControllerBase
    {
        private IProjectService _service;
        public ProjectController(IProjectService service)
        {
            _service = service;
        }

        /// <summary>
        /// 获取分页后项目列表
        /// </summary>
        /// <param name="query">查询参数</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PagePagingDto<ProjectDto>> GetProjectInfoPageDto([FromBody] GetProjectQuery query)
        {
            return await _service.GetProject(query);
        }

        /// <summary>
        /// 添加项目信息
        /// </summary>
        /// <param name="addProjectInfo">项目信息参数</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<BaseResultDto> AddProjectInfo([FromBody] AddProjectInfoQuery addProjectInfo)
        {
            return await _service.AddProject(addProjectInfo);
        }

        /// <summary>
        /// 更新项目信息
        /// </summary>
        /// <param name="updateProjectInfo">更新参数</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<BaseResultDto> UpdateProject([FromBody] UpdateProjectInfoQuery updateProjectInfo)
        {
            return await _service.UpdateInfo(updateProjectInfo);
        }

        /// <summary>
        /// 更新项目状态
        /// </summary>
        /// <param name="updateProjectState">更新参数</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<BaseResultDto> UpdateState([FromBody] UpdateProjectStateQuery updateProjectState)
        {
            return await _service.UpdateState(updateProjectState);
        }

        /// <summary>
        /// 编辑比赛项目时选择项目类别列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultListDto<GetProjectTypeListDto>> GetProjectTypeList()
        {
            return await _service.GetProjectTypeList();
        }

        /// <summary>
        /// 编辑比赛项目时选择项目列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultListDto<GetProjectInfoDto>> GetProjectInfo([FromBody] GetProjectInfoQuery query)
        {
            return await _service.GetProjectInfo(query);
        }

        /// <summary>
        /// 客户端分页获取项目信息（用于信息同步）
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PagePagingDto<GetPageProjectKHDDto>> GetPageProjectKHD([FromBody] BasePageQuery query)
        {
            return await _service.GetPageProjectKHD(query);
        }
    }
}
